package com.weijianhuawen.wjblog.jwt.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description: 密码加密
 * @date: 2024-10-16 0:31
 */
@Configuration
public class PasswordEncoderConfig {

    @Bean
    public PasswordEncoder passwordEncoder() {
        //BCrypt 加盐加密
        return new BCryptPasswordEncoder();
    }

    public static void main(String[] args) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        System.out.println(encoder.matches("123456","$2a$10$t7tpUECQOFzjmh7eSnYHauJ2lbSYca7X.Jl2SgdHkpE/3SbvsVPsW"));
        System.out.println(encoder.encode("weijianhuawen"));
    }
}
